var express = require('express');
var router = express.Router();

model = require('../../models/model')
router.post('/', function(req, res, next) {
  var user = req.body.user;
  var password = req.body.password;
  var directionId=req.body.directionId;
  model.Users.findOne({
    "user": user
  }, function(err, docs) {
    if (null != docs) {
      res.send({err:'error',state:100,msg:'用户名已存在'})
    }else{
      model.Users.create({user:user,password:password,directionId:directionId},function(e,doc){
        res.send({err:'',state:200,msg:'注册成功'})
      })
    }
  });
});
module.exports = router;
